package com.coder520.topic;

import javax.jms.JMSException;

import javax.jms.Message;
import javax.jms.Session;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;

@Component
public class TopicSender {
	@Autowired
	@Qualifier("topicTemplate")
	private  JmsTemplate template;
	
	public void send(String queueName,String message) {
		template.send(queueName,new MessageCreator() {
			@Override
			public Message createMessage(Session session) throws JMSException {
				return session.createTextMessage(message);
		}});
	}
}
